package com.sphd.restaurantsystem.presenter;


import com.android.volley.VolleyError;
import com.sphd.restaurantsystem.info.SalesInfo;
import com.sphd.restaurantsystem.model.StateAModelImpl;
import com.sphd.restaurantsystem.view.StateAView;

import java.util.List;
import java.util.Map;

/**
 * Created by Hu on 2016/12/08
 */

public class StateAPresenterImpl implements StateAPresenter {
    StateAModelImpl stateAModel;
    StateAView stateAView;

    public StateAPresenterImpl(StateAView stateAView) {
        this.stateAView = stateAView;
        stateAModel = new StateAModelImpl();
    }

    @Override
    public void addData(String url) {
        stateAView.showLoading();
        stateAModel.senUrl(url,this);
    }

    @Override
    public void sendError(VolleyError error) {
        stateAView.dissLoading();
    }

    @Override
    public void sendResAndList(int status0sum, int status1sum, int status2sum, int status3sum, int status6sum, List<SalesInfo> salesInfos) {
        stateAView.recResAndList(status0sum,status1sum,status2sum,status3sum,status6sum,salesInfos);
        stateAView.dissLoading();
    }

    @Override
    public void recUrl(String s, Map<String, String> map) {
        stateAModel.recUrlMap(s,map,this);
    }

    @Override
    public void recRes(int res) {
        stateAView.recRes(res);
        stateAView.dissLoading();
    }

    @Override
    public void sendCancleUrl(String s) {
        stateAModel.sendCancleUrl(s,this);
    }

    @Override
    public void recCanRes(int status) {
        stateAView.recCancleRes(status);
        stateAView.dissLoading();
    }
}